package Test;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dusongsong
 * @date 2024年05月27日 16:37
 */
public class PlaceholderUtil {
    private static String TEMPLATE = "姓名：${name!}，年龄：${age!}，手机号：${phone!}";
    private static final Map<String, String> ARGS = new HashMap<String, String>() {{
        put("name", "张三");
        put("phone", "10086");
        put("age", "21");
    }};

    public static void main(String[] args) {
        for (Map.Entry<String, String> entry : ARGS.entrySet()) {
            TEMPLATE = StringUtils.replace(TEMPLATE, "${" + entry.getKey() + "!}", entry.getValue());
        }
        System.out.println(TEMPLATE);

    }

}
